from selenium.webdriver.common.by import By
from po.Base.Base import Base
import time
class Page(Base):
    # 点击登录
    denglu=(By.XPATH,'/html/body/div[1]/div/div[2]/ul/li[1]/a')
    def denglu_loc(self):
        self.click(self.denglu)
    # 输入用户名
    name2=(By.NAME,'username')
    def name_loc(self,name):
        self.send_keys(self.name2,name)
    #     输入密码
    password2=(By.NAME,'password')
    def password_loc(self,password):
        self.send_keys(self.password2,password)
    # 点击登录按钮
    dengluanniu=(By.CLASS_NAME,'finish-btn')
    def dengluanniu_loc(self):
        self.click(self.dengluanniu)
    #     点击首页
    sy=(By.XPATH,'/html/body/div[3]/div[2]/ul/li[1]/a')
    def sy_loc(self):
        self.click(self.sy)


    def a3mall_log(self,name,password):
        try:
            self.goto('http://10.59.9.12:7001/')
            time.sleep(2)
            self.denglu_loc()
            time.sleep(2)
            self.name_loc(name)
            self.password_loc(password)
            time.sleep(10)
            self.dengluanniu_loc()
            time.sleep(2)
            self.sy_loc()
        except Exception as e:
            times = time.strftime('%Y%m%d_%H%M%S', time.localtime())
            self.driver.save_screenshot('hj' + times + '.png')
            print(e)
